from pygame import DOUBLEBUF, QUIT, quit, Surface, init
from pygame.event import get as event_get
from pygame.time import delay
from pygame.display import set_mode, set_caption, flip

__all__=[
    "waitQuit",
    "waiting",
    "getWindow",
]

def waitQuit() -> "bool|None":
    for event in event_get():
        if event.type == QUIT:
            quit()
            return True


def waiting() -> None:
    while True:
        delay(10)
        if waitQuit():
            break


def getWindow(size: "tuple[int]", title: str = "window in pygame") -> Surface:
    init()
    psurface = set_mode(size,DOUBLEBUF)
    set_caption(title)
    psurface.fill((255,)*3)
    flip()
    return psurface
